<?php
$indexadd= ROOT_PATH;
function _whoonline()
{
	$fp = fopen($indexadd."whoonline/guest-".session_id().".txt", 'w');
	fwrite($fp,"o");
	fclose($fp);
    $ol = glob($indexadd."whoonline/*.txt");
    $g = array();
    $k = 0;
    $j = 0;
    $i = 0;
    for (; $i < count($ol); ++$i)
    {
        if (!file_exists($ol[$i]))
        {
            continue;
        }
        else if (300 < time() - filemtime($ol[$i]))
        {
            unlink($ol[$i]);
        }
        else
        {
            ++$k;
        }
    }
    return $k;
}
function visitcount() {
	$fp = fopen($indexadd."vistcount/".session_id().".txt", 'w');
	fwrite($fp,"o");
	fclose($fp);
    $ol = glob($indexadd."vistcount/*.txt");
    $nd = count($ol);    
	// $sqlvist ="Select *from setting where name ='vistcount'";
	// $rsvist = mysql_query($sqlvist) or die(mysql_error());
	// $vistcount = mysql_fetch_object($rsvist);
	// $nd=$vistcount->content +1;
	// $sqlvist ="update setting set content='$nd' where name ='vistcount'";
	// $rsvist = mysql_query($sqlvist) or die(mysql_error());
    // $i=0;
	// $fp = fopen($indexadd.'visit_count.txt', 'a+');
    // $i++;
	// fwrite($fp,"K");
	// fclose($fp);
    // $nd = number_format(filesize($indexadd."visit_count.txt"), 0, ",", ".");
    return $nd;
}
function _dailyhit()
{
    global $cf;
    //cf($cf['sitedir']."dailyhit/".date("Y-m-d", time() + 25200).".txt", "K", "a");
	$fp = fopen($indexadd."dailyhit/".date("Y-m-d", time() + 25200).".txt", 'a');
	fwrite($fp,"K");
	fclose($fp);	
    $k = filesize($indexadd."dailyhit/".date("Y-m-d", time() + 25200).".txt");
    if ($k < 1)
    {
        $k = 1;
    }
    return $k;
}

?>

